<%--
  Created by IntelliJ IDEA.
  User: 陈林
  Date: 2020/5/2
  Time: 18:20
  To change this template use File | Settings | File Templates.
--%>
<%@ page language="java" contentType="text/html; charset=utf-8" isELIgnored="false" pageEncoding="utf-8"%>
<%@ include file="/webpage/common/include/taglib.jsp"%>
<html>
<head>
    <meta charset="utf-8">
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <!--[if lt IE 9]>
    <%@ include file="/webpage/common/include/ltie9.jsp"%>
    <!--<script type="text/javascript" src="/resources/lib/html5shiv.js"></script>-->
    <!--<script type="text/javascript" src="/resources/lib/respond.min.js"></script>-->
    <![endif]-->
    <%--<link rel="stylesheet" type="text/css" href="static/h-ui/css/H-ui.min.css" />--%>
    <link rel="stylesheet" type="text/css" href="${ctxStatic}/h-ui.admin/css/H-ui.admin.css" />
    <%--<link rel="stylesheet" type="text/css" href="lib/Hui-iconfont/1.0.8/iconfont.css" />--%>
    <link rel="stylesheet" type="text/css" href="${ctxStatic}/h-ui.admin/skin/default/skin.css" id="skin" />
    <%--<link rel="stylesheet" type="text/css" href="static/h-ui.admin/css/style.css" />--%>
    <%@include file="/webpage/common/include/head.jsp"%>
    <!--[if IE 6]>
    <%@ include file="/webpage/common/include/ltie6.jsp"%>
    <script type="text/javascript" src="${ctxLib}/DD_belatedPNG_0.0.8a-min.js" ></script>
    <script>DD_belatedPNG.fix('*');</script>
    <![endif]-->
    <title>抄表统计</title>
</head>
<body>
<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i>${pageMenuMsg.firstTitle}<span class="c-gray en">&gt;</span> ${pageMenuMsg.menuName} <span class="c-gray en">&gt;</span> ${pageMenuMsg.secondTitle} <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a></nav>
<div class="page-container">
    <input type="hidden" value="10" name="page.pageSize"/>
    <input type="hidden" name="page.pageNo" value="1"/>
    <div class="text-c"> 日期：
        <input type="text" name="minTime" onfocus="WdatePicker()" id="logmin" class="input-text Wdate" style="width:120px;">
        <button name="" id="searchBtn" class="btn btn-success" type="submit"><i class="Hui-iconfont">&#xe665;</i> 搜索</button>
    </div>
    <div id="container" style="min-width:700px;height:400px"></div>
</div>
<%@include file="/webpage/common/include/footer.jsp"%>
<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="${ctxLib}/My97DatePicker/4.8/WdatePicker.js"></script>
<script type="text/javascript" src="${ctxLib}/hcharts/Highcharts/5.0.6/js/highcharts.js"></script>
<script type="text/javascript" src="${ctxLib}/hcharts/Highcharts/5.0.6/js/modules/exporting.js"></script>
<script type="text/javascript">
    $(function () {
        var monthCStrs = {"01":"一","02":"二","03":"三","04":"四","05":"五","06":"六","07":"七","08":"八","09":"九","10":"十","11":"十一","12":"十二"};
        $("#searchBtn").click(function () {
            var con = $("#logmin").val();
            if(con == "" || con == null){
                layer.alert('输入值不能为空！');
                return;
            }
            getUionCount({'taskTime':new Date(con).format("yyyy-MM-dd"),"month":monthCStrs[new Date(con).format("MM")]});
        });

        //time转换
        Date.prototype.format = function(format) {
            var o = {
                "M+": this.getMonth() + 1, // month
                "d+": this.getDate(), // day
                "h+": this.getHours(), // hour
                "m+": this.getMinutes(), // minute
                "s+": this.getSeconds(), // second
                "q+": Math.floor((this.getMonth() + 3) / 3), // quarter
                "S": this.getMilliseconds()
                // millisecond
            };
            if(/(y+)/.test(format) || /(Y+)/.test(format)) {
                format = format.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
            }
            for(var k in o) {
                if(new RegExp("(" + k + ")").test(format)) {
                    format = format.replace(RegExp.$1, RegExp.$1.length == 1 ? o[k] : ("00" + o[k]).substr(("" + o[k]).length));
                }
            }
            return format;
        };
        getUionCount({'taskTime':new Date().format("yyyy-MM-dd"),"month":monthCStrs[new Date().format("MM")]});
        function getUionCount(params){
            $.ajax({
                url:"/task/watch/addCount",
                data:params,
    			type:'get',
                cache:false,
                dataType: 'json', //服务器返回json格式数据
                type: 'get', //HTTP请求类型
                success: function(data) {
                    console.log(JSON.stringify(data));
                    var fLists = [];
                    var fnLists = [];
                    var ufnLists = [];
                    var average = [];
                    var numTask = 0;
                    var finishNum = 0;
                    var unfinishNum = 0;
                    for(var i=0;i<data.length;i++){
                        if(data[i].status == 1 ){
                            finishNum = finishNum + data[i].addCount;
                        }else if(data[i].status== 0){
                            unfinishNum = unfinishNum + data[i].addCount;
                        }
                    }
                    // fLists = [];
                    // fnLists = [];
                    // ufnLists = [];
                    // average = [];
                    if(data.length == 0){
                        return;
                    }
                    var flag = false;
                    fLists.push(data[0].taskAdd);
                    console.log(JSON.stringify(fLists));
                    for(var j=0;j<data.length;j++  ){
                        for(var i=0;i<fLists.length;i++){
                            if(data[j].taskAdd == fLists[i]){
                                flag = true;
                                break;
                            }
                        }
                        if(!flag && data[j].taskAdd != null){
                            fLists.push(data[j].taskAdd);
                        }else{
                            flag = false;
                        }
                    }
                    var tempf=0;
                    var tempu=0;
                    for(var i=0;i<fLists.length;i++){
                        for(var item in data){
                            if( fLists[i]==data[item].taskAdd && data[item].status == '1'){
                                tempf = data[item].addCount+tempf;

                            }
                            if( fLists[i]==data[item].taskAdd && data[item].status == '0'){
                                tempu = data[item].addCount+tempu;
                            }
                        }

                        if(tempf!= 0 && tempu != 0){
                            fnLists.push(tempf);
                            ufnLists.push(tempu);
                        }else if(tempf>tempu){
                            fnLists.push(tempf);
                            ufnLists.push(0);
                        }else{
                            fnLists.push(0);
                            ufnLists.push(tempu);
                        }
                        tempf=0;
                        tempu=0;

                    }
                    chartWatchCount({"fLists":fLists,"fnLists":fnLists,"ufnLists":ufnLists,"month":params.month});
                },
                error: function(xhr, type, errorThrown) {
                    //异常处理；
                    console.log(type);
                }
            });

        }
    function   chartWatchCount(data){

        $('#container').highcharts({
            chart: {
                type: 'column'
            },
            title: {
                text: data.month+'月份抄表统计'
            },
            // subtitle: {
            //     text: ''
            // },
            xAxis: {
                 categories:data.fLists// [
                //     '一月',
                //     '二月',
                //     '三月',
                //     '四月',
                //     '五月',
                //     '六月',
                //     '七月',
                //     '八月',
                //     '九月',
                //     '十月',
                //     '十一月',
                //     '十二月'
                // ]
            },
            yAxis: {
                min: 0,
                title: {
                    text: '个'
                }
            },
            tooltip: {
                headerFormat: '<span style="font-size:10px;">{point.key}</span><table>',
                pointFormat: '<tr><td style="color:{series.color};padding:10px;width:100%;">{series.name}: </td>' +
                '<td style="padding:10px"><b>{point.y} 个</b></td></tr>',
                footerFormat: '</table>',
                shared: true,
                useHTML: true
            },
            plotOptions: {
                column: {
                    pointPadding: 0.2,
                    borderWidth: 0
                }
            },
            series: [{
                name: '完成抄表',
                data: data.fnLists//[49.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4]

            }, {
                name: '未完成抄表',
                data:data.ufnLists //[83.6, 78.8, 98.5, 93.4, 106.0, 84.5, 105.0, 104.3, 91.2, 83.5, 106.6, 92.3]

             }
             //, {
            //     name: 'London',
            //     data: [48.9, 38.8, 39.3, 41.4, 47.0, 48.3, 59.0, 59.6, 52.4, 65.2, 59.3, 51.2]
            //
            // }, {
            //     name: 'Berlin',
            //     data: [42.4, 33.2, 34.5, 39.7, 52.6, 75.5, 57.4, 60.4, 47.6, 39.1, 46.8, 51.1]
            //
            // }
            ]
        });

    }

    });
</script>
</body>


</html>
